"""Define bazel dependencies."""

module(
    name = "modular",
    version = "0",
)

include("//bazel:common.MODULE.bazel")

mojo_aliases = use_repo_rule("//bazel:mojo_aliases.bzl", "mojo_aliases")

mojo_aliases(name = "mojo")

mblack_alias = use_repo_rule("//bazel:mblack_alias.bzl", "mblack_alias")

mblack_alias(name = "mblack")

modular_wheel_repository = use_repo_rule("//bazel:modular_wheel_repository.bzl", "modular_wheel_repository")

modular_wheel_repository(name = "modular_wheel")

macos_sysroot_repository = use_repo_rule("//bazel/internal/cc-toolchain:macos_sysroot_repository.bzl", "macos_sysroot_repository")

macos_sysroot_repository(name = "sysroot-macos")

include("//bazel:mojo.MODULE.bazel")

register_toolchains(
    "@mojo_toolchains//...",
    "//bazel/internal/cc-toolchain:all",
)

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# This section is derived from the full LLVM workspace, available at
# llvm-project/utils/bazel/WORKSPACE. If there are changes in
# LLVM that require updating these dependencies, this file may also need to
# be updated in the future.
http_archive(
    name = "llvm_zlib",
    build_file = "@llvm-raw//utils/bazel/third_party_build:zlib-ng.BUILD",
    dev_dependency = True,
    sha256 = "e36bb346c00472a1f9ff2a0a4643e590a254be6379da7cddd9daeb9a7f296731",
    strip_prefix = "zlib-ng-2.0.7",
    urls = [
        "https://github.com/zlib-ng/zlib-ng/archive/refs/tags/2.0.7.zip",
    ],
)

http_archive(
    name = "llvm_zstd",
    build_file = "@llvm-raw//utils/bazel/third_party_build:zstd.BUILD",
    dev_dependency = True,
    sha256 = "7c42d56fac126929a6a85dbc73ff1db2411d04f104fae9bdea51305663a83fd0",
    strip_prefix = "zstd-1.5.2",
    urls = [
        "https://github.com/facebook/zstd/releases/download/v1.5.2/zstd-1.5.2.tar.gz",
    ],
)

# NOTE: These versions don't particularly match what modular uses internally, this is only used for test dependencies
LLVM_COMMIT = "f645d209d42c0d4ccb31d48c6663676098d7ec4d"

LLVM_SHA = "78e3990768c2325709f2f5cb54cb193422e35bf4a96ebb8f3de024b371b71dfc"

http_archive(
    name = "llvm-raw",
    build_file_content = "exports_files(glob([\"**\"]))",
    dev_dependency = True,
    sha256 = LLVM_SHA,
    strip_prefix = "llvm-project-{}".format(LLVM_COMMIT),
    url = "https://github.com/llvm/llvm-project/archive/{}.tar.gz".format(LLVM_COMMIT),
)

llvm_configure = use_repo_rule("@llvm-raw//utils/bazel:configure.bzl", "llvm_configure")

llvm_configure(name = "llvm-project")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
    name = "npm",
    data = ["//bazel/lint:package.json"],
    lifecycle_hooks_exclude = [
        "cpu-features",
    ],
    npm_package_lock = "//bazel/lint:package-lock.json",
    pnpm_lock = "//bazel/lint:pnpm-lock.yaml",
    verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm", dev_dependency = True)
use_repo(pnpm, "pnpm")
